<ul class="breadcrumb">
  <li><a href="/">首页</a> <span class="divider">/</span></li>
  <li><a href="/tclasses">课程信息</a> <span class="divider">/</span></li>
  <li class="active">
    <% if !@f_n.nil?&&!@f_n.empty? %>
        <%= @f_n %>
    <% else %>
        所有课程
    <% end %>
  </li>
</ul>
<p>
  <a style="cursor: pointer" onclick="$('#filter').toggle('slow')">选择过滤条件</a> |
  <a href="/tclasses">重置过滤条件</a> |
  <%= link_to '新建课程记录', new_tclass_path %>
</p>
<div id="filter" style="display: none;">
  <form action="/tclasses" method="get">
    <input type="hidden" name="type" value="s"/>

    <p>课程名称包含:<input type="text" name="t" style="width: 90px"/>&nbsp;
      课程描述包含:<input type="text" name="d" style="width: 130px"/>&nbsp;
    </p>

    <p>
      创建时间:从<input type="text" name="s" style="width: 150px"/> 到 &nbsp;<input type="text" name="e" style="width: 150px"/>
    </p>

    <!--<p>上课分组包括:-->
    <% if !@groups.nil? %>
        <% @groups.each do |g| %>
            <input type="checkbox" name="<%= g %>" checked="checked"/>
            <%= g %>&nbsp;
        <% end end %> </p>
    <input type="submit" class="btn primary" value="提交"/>
    <input type="reset" class="btn" value="清空"/>
  </form>
</div>
<script type="text/javascript">
    $(document).ready(function() {
                $("table").tablesorter({
                    sortList: [
                        [2,1]
                    ]  ,
                    headers: { 4: { sorter: false} }
                });
            }
    );

</script>
<table class="zebra-striped bordered-table">
  <thead>
  <tr>
    <th>名称</th>
    <th>描述</th>
    <th>上课时间</th>
    <th>上课分组</th>
    <th>操作</th>
  </tr>
  </thead>
  <tbody>
  <% @tclasses.each do |tclass| %>
      <tr>
        <td><%= link_to truncate(tclass.title, :length=>12), tclass %></td>
        <td><%= truncate(tclass.description, :length=>15) %></td>
        <td><%= tclass.ctime.strftime("%Y-%m-%d  %H:%M") %></td>
        <td><%=
            if tclass.scope.split(',').size ==5
                "所有分组"
            else
                tclass.scope
            end
        %></td>
        <td><%= link_to '查看出勤', :controller => "attendances", :action => "index", :cid=>tclass.id %>
          <%= link_to '导入', :controller => "datainport", :action => "inport_attendance_data", :cid=>tclass.id %>
          <%= link_to '编辑', edit_tclass_path(tclass) %>
          <%= link_to '删除', tclass, confirm: '删除课程会删除相关的所有出勤信息,确认删除?', method: :delete %></td>
      </tr>
  <% end %>
  </tbody>
</table>

